package com.wcity.manage.service.impl;

import com.wcity.manage.dao.dal.model.PageModel;
import com.wcity.manage.dao.mapper.BlockMapper;
import com.wcity.manage.dao.mapper.PropertyOnDutyMapper;
import com.wcity.manage.dao.model.Block;
import com.wcity.manage.dao.model.OnDuty;
import com.wcity.manage.dao.model.User;
import com.wcity.manage.service.property.PropertyOnDutyService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 值班信息管理模块
 * Created by zm on 2016/12/14.
 */
@Service
public class PropertyOnDutyServiceImpl implements PropertyOnDutyService {

    @Resource private PropertyOnDutyMapper propertyOnDutyMapper;
    @Resource private BlockMapper blockMapper;

    /**
     * 获取分页表单
     * @param pageModel
     * @return
     */
    @Override
    public List<OnDuty> getDutyListPage(PageModel pageModel) {
        return propertyOnDutyMapper.findListPage(pageModel);
    }

    /**
     * 添加
     * @param duty
     * @return
     */
    @Override
    public int dutyAdd(OnDuty duty) {
        return propertyOnDutyMapper.insert(duty);
    }

    /**
     * 根据id获取表单数据
     * @param id
     * @return
     */
    @Override
    public OnDuty getDutyInfo(String id) {
        return propertyOnDutyMapper.getDutyInfo( id );
    }

    /**
     * 修改
     * @param duty
     * @return
     */
    @Override
    public int dutyEdit(OnDuty duty) {
        return propertyOnDutyMapper.update(duty);
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @Override
    public int dutyDelect(String id) {
        return propertyOnDutyMapper.delete(id);
    }

    /**
     * 根据小区id获取小区名称
     * @param blockId
     * @return
     */
    @Override
    public Block getBlockName(int blockId) {
        return propertyOnDutyMapper.getBlockName (blockId);
    }

    /**
     * 根据小区id获取值班列表
     * @param pageModel
     * @return
     */
    @Override
    public List<OnDuty> getIDutyList( PageModel pageModel ) {
        return propertyOnDutyMapper.findListPage( pageModel );
    }

    /**
     * 根据小区id获取小区相关信息
     * @param blockId
     * @return
     */
    @Override
    public Block getUserInfo(String blockId) {
        return blockMapper.find( Integer.parseInt(blockId) );
    }
}
